package com.example.netty_pipline.pipeline;

/**
 * ChannelHandlerContext接口 - 处理器上下文
 * 模仿Netty的ChannelHandlerContext，提供事件传播机制
 */
public interface ChannelHandlerContext {
    
    /**
     * 获取pipeline
     */
    ChannelPipeline pipeline();
    
    /**
     * 获取处理器名称
     */
    String name();
    
    /**
     * 获取处理器
     */
    ChannelHandler handler();
    
    // 入站事件传播方法
    ChannelHandlerContext fireChannelActive();
    ChannelHandlerContext fireChannelInactive();
    ChannelHandlerContext fireChannelRead(Object msg);
    ChannelHandlerContext fireChannelReadComplete();
    ChannelHandlerContext fireUserEventTriggered(Object evt);
    ChannelHandlerContext fireExceptionCaught(Throwable cause);
    
    // 出站操作传播方法
    ChannelHandlerContext bind(Object localAddress);
    ChannelHandlerContext connect(Object remoteAddress, Object localAddress);
    ChannelHandlerContext disconnect();
    ChannelHandlerContext close();
    ChannelHandlerContext write(Object msg);
    ChannelHandlerContext flush();
    
    /**
     * 读取操作
     */
    ChannelHandlerContext read();
}